var userid,pGrid;
$(function() {
	$("#form_core").height($(".form_tab").height()-$("#form_option").outerHeight());
	$('#myTabs a').click(function (e) {
		e.preventDefault()
		$(this).tab('show')
	});
	// 明细列表设置
    pGrid = $("#p-div").ligerGrid({
        columns:[
            {display:'cardid',name:'cardid',width:'10',hide:true},
            {display:'授权类别',name:'licensetype',width:'100'},
            {display:'授权名称',name:'licensename',width:'100'},
        ],
        pageSize:20,
        height:'99%',
        width:'96%',
        rownumbers:true,
        frozen:false,
        fixedCellHeight:false,
        enabledEdit:true,
        onSelectRow:function(rowdata, rowindex){$("#txtrowindex").val(rowindex);},
        param_partner:'partner_list',
        alternatingRow: true,
        clickToEdit: true,
        isScroll: false,
        usePager:true,
        editorTopDiff:4,
        editorLeftDiff:2
    });
	
	var query = getQueryString(window.location.toString());
	userid = query.userid;
	ajaxSubmitGet("/employee/searchUser/" + userid, function(data) {
		//绑定数据
		bindValUser(data);
	});
	ajaxSubmitGet("/employeeCard/searchEmployeeCard/" + userid, function(data) {
		//绑定数据
		bindValCar(data);
	});
	
	$("#pageloading").hide();
});

function bindValUser(data) {
    var user_data = data['data'];
    //绑定主表数据
    $("#userid").val(user_data.userid);
    $("#name").val(user_data.name);
    $("#sex").val(user_data.sex);
    $("#nation").val(user_data.nation);
    $("#birthday").val(user_data.birthday);
    $("#address").val(user_data.address);
    $("#ssn").val(user_data.ssn);
    $("#company_id").val(user_data.company_id);
    $("#dept_id").val(user_data.dept_id);
    $("#mobile_phone").val(user_data.mobile_phone);
    $("#fix_phone").val(user_data.fix_phone);
    document.getElementById("image").src = "../../images/sfz.jpg?time="+(10*Math.random())
}

function bindValCar(data){
	var card_data = data['data']; 
	//绑定主表数据 
	$('#cardid').val(card_data.userid);
	$('#cardDept').val(card_data.create_address);
	$('#card_uid').val(card_data.create_uid);
	$('#card_date').val(card_data.create_date);
	//明细列表数据加载
	pGrid.setOptions({
		data : {
			Rows : card_data['items']
		}
	}); //设置数据参数
	pGrid.loadData();//加载数据 
}


//界面的返回处理，实际是关闭标签处理。
function toBack() {
    parent.tabManager.removeTabItem("search_UserS"+userid);
}